package com.ruoyi.biz.service.impl;

import java.util.List;

import com.ruoyi.biz.domain.RepairRecord;
import com.ruoyi.biz.mapper.RepairRecordMapper;
import com.ruoyi.biz.service.IRepairRecordService;
import com.ruoyi.common.annotation.DataScope;
import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.core.domain.model.LoginUser;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * 【请填写功能名称】Service业务层处理
 *
 * @author ruoyi
 * @date 2020-11-30
 */
@Service
public class RepairRecordServiceImpl implements IRepairRecordService
{
    @Autowired
    private RepairRecordMapper repairRecordMapper;

    /**
     * 查询【请填写功能名称】
     *
     * @param repairId 【请填写功能名称】ID
     * @return 【请填写功能名称】
     */
    @Override
    public RepairRecord selectRepairRecordById(Long repairId)
    {
        return repairRecordMapper.selectRepairRecordById(repairId);
    }

    /**
     * 查询【请填写功能名称】列表
     *
     * @param repairRecord 【请填写功能名称】
     * @return 【请填写功能名称】
     */
    @DataScope(deptAlias = "d", userAlias = "u")
    @Override
    public List<RepairRecord> selectRepairRecordList(RepairRecord repairRecord)
    {
        return repairRecordMapper.selectRepairRecordList(repairRecord);
    }

    /**
     * 新增【请填写功能名称】
     *
     * @param repairRecord 【请填写功能名称】
     * @return 结果
     */
    @Override
    public int insertRepairRecord(RepairRecord repairRecord)
    {
        LoginUser loginUser = SecurityUtils.getLoginUser();
        SysUser user = loginUser.getUser();
        repairRecord.setDeptId(user.getDeptId());
        repairRecord.setCreateBy(user.getUserName());
        repairRecord.setCreateTime(DateUtils.getNowDate());
        return repairRecordMapper.insertRepairRecord(repairRecord);
    }

    /**
     * 修改【请填写功能名称】
     *
     * @param repairRecord 【请填写功能名称】
     * @return 结果
     */
    @Override
    public int updateRepairRecord(RepairRecord repairRecord)
    {
        repairRecord.setUpdateTime(DateUtils.getNowDate());
        return repairRecordMapper.updateRepairRecord(repairRecord);
    }

    /**
     * 批量删除【请填写功能名称】
     *
     * @param repairIds 需要删除的【请填写功能名称】ID
     * @return 结果
     */
    @Override
    public int deleteRepairRecordByIds(Long[] repairIds)
    {
        return repairRecordMapper.deleteRepairRecordByIds(repairIds);
    }

    /**
     * 删除【请填写功能名称】信息
     *
     * @param repairId 【请填写功能名称】ID
     * @return 结果
     */
    @Override
    public int deleteRepairRecordById(Long repairId)
    {
        return repairRecordMapper.deleteRepairRecordById(repairId);
    }

    @Override
    public int updateRepairStatus(RepairRecord repairRecord) {
        return repairRecordMapper.updateRepairStatus(repairRecord);
    }

    /**
     * 获取维修人名字
     * @return
     */
    @Override
    public List<String> getRepairNameList() {
        return repairRecordMapper.getRepairNameList();
    }
}
